# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=expose
_pkgname=ExpoSE
pkgver=1144.218d915
pkgrel=3
pkgdesc='A Dynamic Symbolic Execution (DSE) engine for JavaScript'
arch=('any')
groups=('blackarch' 'blackarch-binary' 'blackarch-reversing'
        'blackarch-code-audit')
url='https://github.com/ExpoSEJS/ExpoSE'
license=('MIT')
depends=('nodejs' 'clang' 'gnuplot' 'python2' 'mitmproxy' 'npm' 'libxtst')
makedepends=('git')
source=("git+https://github.com/ExpoSEJS/ExpoSE.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $_pkgname

  npm install
}

package() {
  cd $_pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec ./expoSE ui
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

